////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef __WN_CONCURRENCY_SPIN_MUTEX_H__
#define __WN_CONCURRENCY_SPIN_MUTEX_H__

#include "WNCore/inc/WNTypes.h"

namespace WNConcurrency {
    class WNSpinMutex {
    public:
        WN_FORCE_INLINE WNSpinMutex();

        WN_FORCE_INLINE WN_VOID Lock();
        WN_FORCE_INLINE WN_BOOL TryLock();
        WN_FORCE_INLINE WN_VOID Unlock();

    private:
        WNSpinMutex(const WNSpinMutex&);
        WNSpinMutex& operator = (const WNSpinMutex&);

    private:
        WN_ATOM_T mSpinFlag;
    };
}

#include "WNConcurrency/inc/WNSpinMutex.inl"

#endif // __WN_CONCURRENCY_SPIN_MUTEX_H__